<style>
    .panel{
        margin-bottom: 10px;
    }
    .panel-body{
        padding: 10px 15px;
    }
</style>

<div class="container-fluid">

    <div class="row panel panel-default">
        <div class="panel-body">
            <a href="{:url('index/index')}">主页</a>
            <span>/</span>
            <span>归档</span>
        </div>
    </div>

    <div class="row panel panel-default">
        <div class="panel-body" style="color: #31708f">
            <span class="fa fa-hand-o-right"></span>
            归档说明：
            本功能可以一次性将我校资产的所有数据进行全部归档，由于数据量特别大，
            而且需要回溯计算，归档时间较慢，请耐心等待。
        </div>
    </div>

    <div class="row panel panel-default">
        <div class="panel-body">
            <div class="form-inline">
                <label>请选择归档年月：</label>
                <input id="yearmonth" placeholder="0000-00" class="form-control">
                &nbsp;&nbsp;
                <button class="btn btn-sm btn-info" onclick="archive()">开始归档</button>
            </div>
        </div>
    </div>

    <div class="row panel panel-default">
        <div class="panel-heading" style="font-weight: bold">归档记录</div>
        <div class="panel-body">
            <table id="logListTable"></table>
        </div>
    </div>

</div>

<script>

    $(function () {
        var h = $(window).height();
        $("#logListTable").bootstrapTable({
            url:'getLogList',
            method:'post',
            sidePagination: 'server',
            pagination:true,
            pageSize:20,
            pageList:[10,20,50],
            pageNumber:1,
            height:h - 360,
            columns:[{
                title:'记录编号',
                field:'LOG_ID',
                sortable:true
            },{
                title:'归档年月',
                field:'YEARMONTH',
                sortable:true
            },{
                title:'操作人',
                field:'USER_NAME',
                sortable:true
            },{
                title:'操作时间',
                field:'CREATE_TIME',
                sortable:true,
            }],
            queryParams:function (params) {
                return params;
            },
            responseHandler:function (res) {
                return res;
            }
        });
    });

    /**
     * 执行归档操作
     */
    function archive() {
        var yearmonth = $("#yearmonth").val();
        if(yearmonth == ''){
            layer.alert('请输入归档年月');
            return;
        }
        layer.confirm('确认执行归档操作吗？',function (index) {
            layer.close(index);

            ajax("{:url('doArchive')}",{yearmonth:yearmonth},function (data) {
                $("#logListTable").bootstrapTable('refresh');
            });
        });
    }

</script>